/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 * Description: 集合通信ai-cpu侧接口声明
 * Author: wangke
 * Create: 2022-12-19
 */
#ifndef HCCL_CPU_KERNEL_H
#define HCCL_CPU_KERNEL_H
#include <map>
#include <mutex>

/*******************************aicpu single stream interface begin***************************************/
// pass
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

uint32_t HdcsGetPid(void *args);

/***
 * 初始化通信域，保存rank信息，worker信息，调用现有的CsInit
 * workerList：worker的rankId的数组
 * psList：ps的rankId的数组
 * rankId：当前rank的rankId
***/
uint32_t HdcsCsInit(void *args);

uint32_t HdcsCsDeInit();

/***
 * tag：用于区分不同算子
 * links：link的数组，下标表示psId
***/
uint32_t HdcsRegTransport(void *args);

uint32_t HdcsRemoteLookup(void *args);

uint32_t HdcsCollRemoteUpdate(void *args);

// update ReduceSum
uint32_t HdcsCollRemoteUpdateReduceSum(void *args);

// update KeyReduce
uint32_t HdcsCollRemoteUpdateKeyReduce(void *args);

// update send keys and value
uint32_t HdcsCollRemoteUpdateSendRequest(void *args);

uint32_t HdcsCollRemoteUpdateResetUniqueHandle(void *args);

// update recv Response
uint32_t HdcsCollRemoteUpdateRecvResponse(void *args);
/*******************************aicpu single stream interface end***************************************/

/*******************************aicpu multi stream pipeline interface begin***************************************/
// lookup 去重+sendbuf 准备
uint32_t HdcsCollLookupKeysDuplicates(void *args);

// lookup send keys
uint32_t HdcsCollLookupSendKeys(void *args);

// lookup recv values
uint32_t HdcsCollLookupRecvValues(void *args);

// lookup recover value
uint32_t HdcsCollLookupRecoverValue(void *args);

// lookup reset unique handle
uint32_t HdcsCollLookupResetUniqueHandle(void *args);

uint32_t HdcsCollLookupWaitSendKeyFinish(void *args);

uint32_t HdcsCollLookupGatherFinish(void *args);
/*******************************aicpu multi stream pipeline interface end***************************************/

/*******************************aicpu interface begin***************************************/
uint32_t HdcsChkServiceCancel(void *args);
/*******************************aicpu interface end***************************************/
#ifdef __cplusplus
}
#endif // __cplusplus
#endif